package com.smmisia.shop.entity.convetor;

import com.smmisia.shop.entity.Product;
import com.smmisia.shop.model.ProductVO;
import com.smmisia.shop.request.ProductCreateRequest;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface ProductConvertor {

    ProductConvertor INSTANCE = Mappers.getMapper(ProductConvertor.class);

    public static final int DEFAULT_MIN_SALE_TIME = 60;

    /**
     * 转换为VO
     *
     * @param request
     * @return
     */
    @Mapping(target = "state", ignore = true)
     ProductVO mapToVo(Product request);

    /**
     * 转换为VO
     *
     * @param request
     * @return
     */
    List<ProductVO> mapToVo(List<Product> request);

    Product mapToEntity(ProductCreateRequest request);
}
